package lab02.test21;

/**
 * Created by lenovo on 2017/10/31.
 */
public class Test {
    public static void main(String[] args) {
        //统计一个字符串中给定字符出现的频率
        String results = "helloworld";
        double rate = 0;
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < results.length(); i++) {
            char tmp = results.charAt(i);
            if (tmp == 'l') {
                stringBuffer.append(tmp);
            }
        }
        rate = stringBuffer.length() * 0.1 / results.length() * 1000;
        System.out.println("l字符出现的频率:" + rate + "%");
    }
}
